package com.dinggou.shopjb.adapters;

import android.content.Context;
import android.view.View;
import android.widget.ImageView;
import android.widget.TextView;

import com.dinggou.shopjb.R;
import com.dinggou.shopjb.base.BaseRVAdapter;
import com.dinggou.shopjb.base.BaseRVHolder;
import com.dinggou.shopjb.bean.TicketBean;

import java.util.List;

public class TicketAdapter extends BaseRVAdapter {
    public TicketAdapter(Context context, List list) {
        super(context, list);
    }

    @Override
    public int onCreateViewLayoutID(int viewType) {
        return R.layout.item_ticket_list;
    }

    @Override
    public void onBindView(BaseRVHolder holder, int position) {
        TextView tv_build_time = holder.getViewHolder().get(R.id.tv_build_time);
        TextView tv_expiration_time = holder.getViewHolder().get(R.id.tv_expiration_time);
        TextView tv_ticket_money = holder.getViewHolder().get(R.id.tv_ticket_money);
        TextView bt_to_use = holder.getViewHolder().get(R.id.bt_to_use);
        ImageView iv_status = holder.getViewHolder().get(R.id.iv_status);

        TicketBean bean =(TicketBean)mList.get(position);

        if (bean.getType().equals("1")){
            bt_to_use.setVisibility(View.VISIBLE);
            iv_status.setVisibility(View.GONE);
        }else if (bean.getType().equals("2")){
            bt_to_use.setVisibility(View.GONE);
            iv_status.setVisibility(View.VISIBLE);
            iv_status.setImageResource(R.drawable.ic_ticket_used);
        }else if (bean.getType().equals("3")){
            bt_to_use.setVisibility(View.GONE);
            iv_status.setVisibility(View.VISIBLE);
            iv_status.setImageResource(R.drawable.ic_ticket_expired);
        }

        tv_build_time.setText(bean.getAdd_date());
        tv_expiration_time.setText(bean.getEnd_date());
        tv_ticket_money.setText(bean.getSum()+"");
    }
}
